package com.itheima01;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class Test04 {
    public static void main(String[] args) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException, ClassNotFoundException {

        Class clazz = Class.forName("com.itheima01.Teacher");

        Teacher tea = (Teacher) clazz.getDeclaredConstructor().newInstance();

        Method[] declaredMethods = clazz.getDeclaredMethods();
        for (Method declaredMethod : declaredMethods) {
            System.out.println(declaredMethod);
        }
        System.out.println("--------------------------");

        Method m = clazz.getDeclaredMethod("function4", String.class);

        Object invoke = m.invoke(tea, "java");

        System.out.println(invoke);

    }
}
